<%@ page language="java" 
    import="weixin.mp.api.*,com.wx.*,weixin.mp.bean.result.*"
	pageEncoding="UTF-8"%><%
	response.addHeader("Access-Control-Allow-Origin","*");// new add 
	response.addHeader("Access-Control-Max-Age","600");// new add 
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
	
	WxMpService wxMpService=WxUtil.getInstance();
	
	String code=(String)request.getParameter("code");
	String state=(String)request.getParameter("state");
	
	WxMpOAuth2AccessToken wxMpOAuth2AccessToken=wxMpService.oauth2getAccessToken(code);
	//WxMpUser wxMpUser = wxMpService.oauth2getUserInfo(wxMpOAuth2AccessToken, null);
	String openid=wxMpOAuth2AccessToken.getOpenId();
    String ac =wxMpOAuth2AccessToken.getAccessToken();


    System.out.println(openid+"here");

/*	String baseUrl="http://123.57.206.149/";
	if(state!=null && state.equals("myIceAlliance")){
		response.sendRedirect(baseUrl+"?data="+openid);
	}else if(state!=null && state.equals("myorder")){
		response.sendRedirect(baseUrl+"direct_user_order?data="+openid);
	}else if(state!=null && state.equals("myhobby")){
		response.sendRedirect(baseUrl+"direct_user_hobby?data="+openid);
	}else if(state!=null && state.equals("club")){
		response.sendRedirect(baseUrl+"club?data="+openid);
	}else if(state!=null && state.equals("space")){
		response.sendRedirect(baseUrl+"space?data="+openid);
	}else if(state!=null && state.equals("clublist")){
		response.sendRedirect(baseUrl+"clublist?data="+openid);
	}else if(state!=null && state.equals("feedback")){
		response.sendRedirect(baseUrl+"feedback?data="+openid);
	}*/


%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="冰盟授权页面">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  </head>
  
  <body>
    <%--<%=openid %> <br>
    <%=ac %> <br--%>>
 <%	response.sendRedirect("https://api.weixin.qq.com/sns/userinfo?access_token=" + ac + "&openid=" + openid); %>
    
    
  </body>
</html>
